package cn.lili.controller.payment;

import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.kit.params.WithdrawParams;
import cn.lili.modules.payment.entity.dos.UserPointsHistory;
import cn.lili.modules.payment.service.LiUserPointsHistoryService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*;

@Api(tags = "绿色积分记录表")
@RestController
@RequestMapping("/payment/point/history")
public class LiUserPointHistoryController {
    @Autowired
    @Lazy
    private LiUserPointsHistoryService pointsHistoryService;

    /**
     * 绿色积分，记录分页查询
     * @return 绿色积分记录
     */
    @GetMapping("/page")
    public ResultMessage<Page<UserPointsHistory>> pointsPage(WithdrawParams withdrawParams) {
        return pointsHistoryService.pointsPage(withdrawParams);
    }

    /**
     * 积分提现
     * @param withdrawParams 提现
     * @return 是否成功
     */
    @PostMapping("/withdraw")
    public ResultMessage<Object> withdraw(@RequestBody WithdrawParams withdrawParams) {
        return pointsHistoryService.withdraw(withdrawParams);
    }

}
